home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 23 / Amiga Format AFCD23 (Feb 1998, Issue 107).iso / -seriously_amiga- / shareware / programming / e / easyplugins / examples / simplegauge_demo.e < prev    next >
Text File  |  1997-12-06  |  3KB  |  114 lines

  1. /*
  2.  
  3.    SimpleGauge Demo
  4.  
  5.    (a little bit silly demo but I think it shows how it works)
  6.  
  7.    Copyright: Ralph Wermke of Digital Innovations
  8.    EMail    : wermke@gryps1.rz.uni-greifswald.de
  9.    WWW      : http://www.user.fh-stralsund.de/~rwermke/di.html
  10.  
  11. */
  12.  
  13. OPT PREPROCESS
  14.  
  15. MODULE 'tools/easygui','tools/exceptions',
  16.        'utility/tagitem',
  17.        'easyplugins/simplegauge'
  18.  
  19. DEF gh
  20.  
  21. PROC main() HANDLE
  22. DEF mp:PTR TO simplegauge_plugin, mp2:PTR TO simplegauge_plugin
  23.  
  24.    -> create new instances
  25.    NEW mp.simplegauge([PLA_SimpleGauge_ShowText, TRUE,
  26.                        PLA_SimpleGauge_Max, 1500,
  27.                        PLA_SimpleGauge_Current, 500,
  28.                        TAG_DONE])
  29.  
  30.    NEW mp2.simplegauge([PLA_SimpleGauge_Horizontal, FALSE,
  31.                         PLA_SimpleGauge_ShowText, TRUE,
  32.                         PLA_SimpleGauge_Max, 1500,
  33.                         TAG_DONE])
  34.  
  35.    -> initial settings
  36.    mp.set(PLA_SimpleGauge_Max, 5000)
  37.    mp.set(PLA_SimpleGauge_Current, 2500)
  38.    mp2.set(PLA_SimpleGauge_BackgroundPen, 3)
  39.    mp2.set(PLA_SimpleGauge_BarPen, 0)
  40.  
  41.    -> open gui
  42.    easyguiA('SimpleGauge Test',
  43.             [ROWS,
  44.                [COLS,
  45.                   [BUTTON, {ignore}, '   '],
  46.                   [PLUGIN, {ignore}, mp]
  47.                ],
  48.                [BEVEL,
  49.                   [COLS,
  50.                      [PLUGIN, {ignore}, mp2],
  51.                      [ROWS,
  52.                         [SPACE],
  53.                         [EQCOLS,
  54.                            [SBUTTON, {setmax}, 'Max=500', [mp,mp2,500]],
  55.                            [SBUTTON, {setmax}, 'Max=1000', [mp,mp2,1000]],
  56.                            [SBUTTON, {setmax}, 'Max=1500', [mp,mp2,1500]],
  57.                            [SLIDE, {scroll}, NIL, FALSE, 0, 1500, 0, 2, '', [mp,mp2]]
  58.                         ],
  59.                         [SBUTTON, {dis}, 'Toggle', [mp,mp2]]
  60.                      ]
  61.                   ]
  62.                ]
  63.             ],
  64.             [EG_GHVAR,{gh}, TAG_DONE])
  65. EXCEPT
  66.    END mp
  67.    report_exception()
  68. ENDPROC
  69.  
  70. PROC ignore(info, mp:PTR TO simplegauge_plugin) IS EMPTY
  71.  
  72. -> set a new maximum
  73. PROC setmax(l:PTR TO LONG, info)
  74. DEF mp:PTR TO simplegauge_plugin, mp2:PTR TO simplegauge_plugin
  75.  
  76.    mp:=l[0]; mp2:=l[1]
  77.    mp.set(PLA_SimpleGauge_Max, l[2])
  78.    mp2.set(PLA_SimpleGauge_Max, l[2])
  79.  
  80. ENDPROC
  81.  
  82. -> set and display scroller value
  83. PROC scroll(l:PTR TO LONG, info, x)
  84. DEF mp:PTR TO simplegauge_plugin, mp2:PTR TO simplegauge_plugin
  85.  
  86.    mp:=l[0]; mp2:=l[1]
  87.  
  88.    IF (x>(mp.get(PLA_SimpleGauge_Max)*0.9))
  89.       mp.set(PLA_SimpleGauge_BarPen, 1)
  90.    ELSE
  91.       mp.set(PLA_SimpleGauge_BarPen, 3)
  92.    ENDIF
  93.  
  94.    mp.set(PLA_SimpleGauge_Current, x)
  95.    mp2.set(PLA_SimpleGauge_Current, x)
  96.  
  97.    PrintF('Max=\d Current=\d Percent=\d\n', mp.get(PLA_SimpleGauge_Max),
  98.                                             mp.get(PLA_SimpleGauge_Current),
  99.                                             mp.get(PLA_SimpleGauge_Percent),
  100.          )
  101.  
  102. ENDPROC
  103.  
  104. -> disables the gauges
  105. PROC dis(l:PTR TO LONG, info)
  106. DEF mp:PTR TO simplegauge_plugin, mp2:PTR TO simplegauge_plugin
  107.  
  108.    mp:=l[0]; mp2:=l[1]
  109.    mp.set(PLA_SimpleGauge_Disabled, Not(mp.get(PLA_SimpleGauge_Disabled)))
  110.    mp2.set(PLA_SimpleGauge_Disabled, Not(mp2.get(PLA_SimpleGauge_Disabled)))
  111.  
  112. ENDPROC
  113.  
  114.